package cn.leetcode;

public class Code230 {

    public int kthSmallest(TreeNode root, int k) {
        fun(root, k);
        return res;
    }
    int res = 0;
    int count = 0;

    public void fun(TreeNode root, int k) {
        if(root == null){
            return;
        }
        fun(root.left, k);
        count++;
        if(count == k){
            res = root.val;
            return;
        }
        fun(root.right, k);
    }
}
